import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

import axios from 'axios'
Vue.prototype.$axios = axios
axios.defaults.baseURL = "http://kansuv.info:13307" //上线接口
//axios.defaults.baseURL = "http://kansuv.info:13780" //测试接口

//获取localStorage数据
store.commit("getlocalStorage");
//过期验证
store.commit("setPast");


// 请求头token
axios.defaults.headers['Authorization'] = store.state.token; //store里也需要添加此条，否则第一次登陆跳转token将会未及时刷新
axios.defaults.headers.post['Content-Type'] = 'application/json;charset=utf-8';

// 响应拦截器
axios.interceptors.response.use(
  function (res) {
    if (res.status == 403) {
      store.commit("clean");
    } else {
      return res;
    }
  },
  function (error) {
    return Promise.reject(error);
  }
);
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
